﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Public;

namespace DAL
{
    public class SoHoKhauDAL
    {
        public static List<SoHoKhauPublic> LoadSoHoKhau()
        {
            var sohokhau = Common.db.ExecuteStoreQuery<SoHoKhauPublic>(@"select MaSHK,SoNha,Duong,KhuPho from SoHoKhau");
            return sohokhau.ToList();
        }

        public static SoHoKhauPublic LoadSoHoKhauByMaSHK(int MaSHK)
        {
            string sql = @"select MaSHK,SoNha,Duong,KhuPho from SoHoKhau where MaSHK=" +MaSHK;
            var sohokhau = Common.db.ExecuteStoreQuery<SoHoKhauPublic>(sql);
            return sohokhau.ToList()[0];
        }
        public static void InsertSoHoKhau(SoHoKhauPublic _shk)
        {
            SoHoKhau shk = new SoHoKhau();
            shk.MaSHK = _shk.MaSHK;
            shk.SoNha = _shk.SoNha;
            shk.Duong = _shk.Duong;
            shk.KhuPho = _shk.KhuPho;
            Common.db.AddToSoHoKhaus(shk);
            Common.db.SaveChanges();
        }
    }
}
